package com.ruoyi.order.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.app.Vo.CartItem;
import com.ruoyi.order.domain.app.Vo.UserAddr;
import com.ruoyi.order.domain.app.from.OrderDetailsResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.OrderAddressMapper;
import com.ruoyi.order.domain.OrderAddress;
import com.ruoyi.order.service.IOrderAddressService;
import com.ruoyi.common.core.text.Convert;

/**
 * 订单地址Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-02-08
 */
@Service
public class OrderAddressServiceImpl implements IOrderAddressService 
{
    @Autowired
    private OrderAddressMapper orderAddressMapper;

    /**
     * 查询订单地址
     * 
     * @param id 订单地址主键
     * @return 订单地址
     */
    @Override
    public OrderAddress selectOrderAddressById(Integer id)
    {
        return orderAddressMapper.selectOrderAddressById(id);
    }

    /**
     * 查询订单地址列表
     * 
     * @param orderAddress 订单地址
     * @return 订单地址
     */
    @Override
    public List<OrderAddress> selectOrderAddressList(OrderAddress orderAddress)
    {
        return orderAddressMapper.selectOrderAddressList(orderAddress);
    }

    /**
     * 新增订单地址
     * 
     * @param orderAddress 订单地址
     * @return 结果
     */
    @Override
    public int insertOrderAddress(OrderAddress orderAddress)
    {
        orderAddress.setCreateTime(DateUtils.getNowDate());
        return orderAddressMapper.insertOrderAddress(orderAddress);
    }

    /**
     * 修改订单地址
     * 
     * @param orderAddress 订单地址
     * @return 结果
     */
    @Override
    public int updateOrderAddress(OrderAddress orderAddress)
    {
        orderAddress.setUpdateTime(DateUtils.getNowDate());
        return orderAddressMapper.updateOrderAddress(orderAddress);
    }

    /**
     * 批量删除订单地址
     * 
     * @param ids 需要删除的订单地址主键
     * @return 结果
     */
    @Override
    public int deleteOrderAddressByIds(String ids)
    {
        return orderAddressMapper.deleteOrderAddressByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除订单地址信息
     * 
     * @param id 订单地址主键
     * @return 结果
     */
    @Override
    public int deleteOrderAddressById(Integer id)
    {
        return orderAddressMapper.deleteOrderAddressById(id);
    }

    @Override
    public OrderDetailsResultVo getOrderPayInfoByOrderNumber(String orderNumbers) {
        Map<String,Object> map = new HashMap<>();
        map.put("orderNO",orderNumbers);
        OrderDetailsResultVo list = orderAddressMapper.getOrderPayInfoByOrderNumber(map);
        return list;
    }

    @Override
    public List<String> getOrderNames(String orderNumbers) {
        Map<String,Object> map = new HashMap<>();
        map.put("orderNO",orderNumbers);
        List<String> list = orderAddressMapper.getOrderNames(map);
        return list;
    }

    @Override
    public UserAddr getAddressrDto(String orderNumber) {
        Map<String,Object> map = new HashMap<>();
        map.put("orderNO",orderNumber);
        UserAddr userAddr= orderAddressMapper.getAddress(map);
        return userAddr;
    }


}
